<template>
  <view>
    <u-tabbar :value="currentTab" :fixed="true" activeColor="#d81e06" :placeholder="false" @change="changeTabIndex">
      <u-tabbar-item v-for="item in switchTabs" :key="item.name" :text="item.text" :icon="item.iconName">
      </u-tabbar-item>
    </u-tabbar>
  </view>
</template>

<script>
  export default {
    name: "my-tabbar",
    data() {
      return {
        switchTabs: [{
            "pagePath": "/pages/main/main",
            "iconName": "home",
            "text": "首页",
            "name": "home"
          },
          {
            "pagePath": "/pages/mine/mine",
            "iconName": "account",
            "text": "我的",
            "name": "mine"
          }
        ]
      }
    },
    props: ['currentTab'],
    methods: {
      changeTabIndex(e) {
        let pagePath = this.switchTabs[e].pagePath
        uni.switchTab({
          url: pagePath
        })
      }
    }
  }
</script>

<style lang="scss">

</style>